package com.billionsfinance.hessian.core;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @ FileName: HessianCacheManager.java
 * @ Author: WeiHui-Z
 * @ Date: 2016-11-24  15:42
 * @ Version: v1.0.0
 */
public class HessianCacheManager {

	private static Map<String, Class<?>> HESSIAN_SERVER_INTERFACE_MAP = new ConcurrentHashMap<>();

	private static Map<String, Class<?>> HESSIAN_SERVER_CLASS_MAP = new ConcurrentHashMap<>();

	/**
	 * 缓存服务端信息
	 *
	 * @param interfaceName    接口名
	 * @param serviceClassName 实现名
	 */
	public static void setHessianServerInfo(Class<?> interfaceName, Class<?> serviceClassName) {
		HESSIAN_SERVER_INTERFACE_MAP.put(interfaceName.getSimpleName(), interfaceName);
		HESSIAN_SERVER_CLASS_MAP.put(interfaceName.getSimpleName(), serviceClassName);
	}

	public static Class<?> getHessianServerInterfaceClass(String interfaceName) {
		return HESSIAN_SERVER_INTERFACE_MAP.get(interfaceName);
	}

	public static Class<?> getHessianServerClass(String serviceClassName) {
		return HESSIAN_SERVER_CLASS_MAP.get(serviceClassName);
	}
}
